<template>
  <div class="container">
    <Breadcrumb :items="['数据上报', '输入导入']" />
    <a-card class="general-card" style="padding-top:20px">
      <a-row>
        <a-upload style="margin: 20px 50px;" 
                  action="/" 
                  class="uploadDiv" 
                  accept=".xls,.xlsx" 
                  :auto-upload="false" 
                  :limit="1" 
                  ref="uploadRef" 
                  @change="onFileChange">
        </a-upload>
          <p style="margin-left: 70px;margin-top:50px">仅允许导入 xls、xlsx 格式文件。
              <a-link @click="jumpDowmTemp">
                  <template #icon>
                      <icon-edit />
                  </template>
                  下载模板
              </a-link>
          </p>
      </a-row>
    </a-card>
  </div>
</template>
<script lang="ts" setup>import { ref, reactive } from 'vue';
import { Modal, Message } from '@arco-design/web-vue';
import { postRequest, uploadFileRequest } from '@/api/common';
import { baseURL } from '@/api/base';


// 
const toLeadVisible = ref(false);
//fileFlag
const upLoadFileFlag = ref(false);
//toLeadForm 上传文件
let toLeadForm: FormData = new FormData();

let sumData = reactive({
    index: '合计',
    problemsFoundCount: 0,
    closedCount: 0 as any,
    inProgressCount: 0,
    disciplinaryCases: 0,
    punishedPersons: 0,
    disciplinaryPunishedPersons:0,
    circularIssues: 0 as any,
    recommendationLetters: 0,
    establishedSystems:0
  })

const onFileChange = (fileList: any) => {
  console.log(fileList);
  if(fileList!=null && fileList.length>0){
    upLoadFileFlag.value = true; //by guo 2020-8-4-15:18添加
    toLeadForm = new FormData();
    toLeadForm.append("file", fileList[0].file);
    toLeadForm.append("userName", localStorage.getItem("userName") as any);
  }else{
    upLoadFileFlag.value = false; //by guo 2020-8-4-15:18添加
    toLeadForm = new FormData();
  }
};
const jumpDowmTemp = ()=>{
  const department = localStorage.getItem("department");
  //  console.log(departmentName);
   window.location.href = baseURL + 'dsms/jyData/downExcelData?department='+department;
}

</script>
<script lang="ts">
export default {
  name: 'dataUpload',
};
</script>
<style scoped lang="less">
::v-deep(.arco-upload-progress){
  visibility: hidden;
}
.container {
  padding: 0 20px 20px 20px;
}
::v-deep(.arco-form-item){
  margin-bottom: 10px;
}
.bg-color-yellow{
  color:yellow;
}
</style>